package com.binguo.service;

import com.binguo.model.model.Branch;
import com.binguo.model.repository.BranchRepository;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Condition;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yuritian
 * @Title: BranchService
 * @ProjectName binguoDevelop
 * @Description: TODO
 * @date 2020/5/2216:00
 */
@Service
public class BranchService {

    @Resource
    private BranchRepository branchRepository;

    public Branch checkBranchName(String branchName){
        Condition condition = new Condition(Branch.class);
        condition.or().andEqualTo("branchName",branchName);
        List<Branch> branchList = branchRepository.findByCondition(condition);
        if (null == branchList || branchList.size() == 0){
            return null;
        }else {
            return branchList.get(0);
        }
    }
}
